{% extends 'base.html' %}
{% block title %}用户登录{% endblock %}
{% block content %}
    <div class="container py-5">
        <div class="row justify-content-center">
            <div class="col-md-4">
                <div class="card shadow">
                    <div class="card-body">
                        <h2 class="text-center">登录</h2>
                        {% if error %}
                        <div style="color: red;">{{ error }}</div>
                        {% endif %}
                        <form method="post" class="mt-4">
                            {% csrf_token %}
                            <!-- 通过{% csrf_token %}标签生成CSRF令牌，确保表单提交的安全性。 -->
                            <div class="mb-3">
                                <label for="id_username" class="form-label">用户名</label>
                                <input type="text" name="username" id="id_username" class="form-control" required>
                            </div>
                            <div class="mb-3">
                                <label for="id_password" class="form-label">密码</label>
                                <input type="password" name="password" id="id_password" class="form-control" required>
                            </div>
                            <button type="submit" class="btn btn-primary w-100">登录</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}